<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <title>Gerenciamento de produtos</title>
    </h:head>
    <h:body>

        <h:form>

            <p:layout fullPage="true">

                <p:layoutUnit position="south" size="60" style="text-align: center">
                    
                    <p:commandButton actionListener="#{vendaBean.cancelarPedido()}" 
                                     value="Cancelar pedido" ajax="false"/>                    
                    
                    <p:commandButton actionListener="#{vendaBean.fecharPedido()}" 
                                     value="Fechar pedido" ajax="false"/>                    
                    <p:button outcome="produtos" value="Cadastrar item"/>                    
                    <p:button outcome="categorias" value="Cadastrar Categorias"/>
                    <p:button outcome="categorias" value="Relatórios"/>
                </p:layoutUnit>

                <p:layoutUnit position="center">
                    <p:inputText style="width: 98%; height: 40px; margin-bottom: 20px;" 
                                 readonly="true" value="#{vendaBean.valorPedido}"/>
                    
                    <ui:repeat value="#{produtoBean.listar}" var="prod">
                        <div id="#{prod.id}" style="float:left; margin-left: 20px;">
                            <p:panelGrid columns="2">
                                <f:facet name="header">
                                    <h:commandLink action="#{vendaBean.comprar(prod)}">
                                        <h:graphicImage value="resources/imgLanches/#{prod.imagem}"/>
                                    </h:commandLink>
                                </f:facet>

                                <h:outputText value="Nome:" />
                                <h:outputText value="#{prod.nome}" />
                                <h:outputText value="Preço:" />
                                <h:outputText value="#{prod.preco}" />
                            </p:panelGrid>
                        </div>
                    </ui:repeat>
                </p:layoutUnit>

            </p:layout>
        </h:form>

    </h:body>
</html>